package com.hmall.api.config;

import com.hmall.api.client.fallback.CartClientFallbackFactory;
import com.hmall.api.client.fallback.ItemClientFallbackFactory;
import com.hmall.api.client.fallback.TradeClientFallbackFactory;
import com.hmall.api.client.fallback.UserClientFallbackFactory;
import com.hmall.api.interceptor.UserInfoInterceptor;
import feign.Logger;
import feign.RequestInterceptor;
import org.springframework.context.annotation.Bean;

//这里想要生效,在启动类上加注解
public class DefaultFeignConfig {

    @Bean
    public Logger.Level feignConfig() {
        return Logger.Level.NONE;
    }

    //拦截器的配置类,返回一个拦截器对象
    @Bean
    public RequestInterceptor userInfoInterceptor() {
        return new UserInfoInterceptor();
    }

    //注册ItemClientFallbackFactory bean对象
    @Bean
    public ItemClientFallbackFactory itemClientFallbackFactory() {
        return new ItemClientFallbackFactory();
    }

    @Bean
    public CartClientFallbackFactory cartClientFallbackFactory() {
        return new CartClientFallbackFactory();
    }

    @Bean
    public TradeClientFallbackFactory tradeClientFallbackFactory() {
        return new TradeClientFallbackFactory();
    }

    @Bean
    public UserClientFallbackFactory userClientFallbackFactory() {
        return new UserClientFallbackFactory();
    }
}
